package script.learn
{
	import laya.events.Event;
	
	import model.ConstantModel;
	import model.Userdata;
	
	import script.ViewManager;
	import script.baseView.BaseViewController;
	
	import ui.tabview.ChooseSubjectPanelUI;
	
	public class ChooseSubjectController extends BaseViewController
	{
		private var uiSkin:ChooseSubjectPanelUI;
		
		public function ChooseSubjectController()
		{
			super();
		}
		
		override public function onStart():void
		{
			uiSkin = this.owner as ChooseSubjectPanelUI;
			
			uiSkin.englishbtn.on(Event.CLICK,this,onLearnEnglish);
			uiSkin.chinesebtn.on(Event.CLICK,this,onLearnChinese);

			uiSkin.mathbtn.on(Event.CLICK,this,onLearnmath);

		}
		
		private function onLearnEnglish():void
		{
			ViewManager.instance.openView(ViewManager.VIEW_CHOOSE_CLASSLEVEL_PANEL,false,ConstantModel.SUBJECT_ENGLISH);
			
		}
		
		private function onLearnChinese():void
		{
			ViewManager.instance.openView(ViewManager.VIEW_CHOOSE_CLASSLEVEL_PANEL,false,ConstantModel.SUBJECT_CHINESE);
			
		}
		
		private function onLearnmath():void
		{
			if(Userdata.instance.curState == ConstantModel.LEARN_MODEL)
				ViewManager.instance.openView(ViewManager.VIEW_CHOOSE_CLASSLEVEL_PANEL,false,ConstantModel.SUBJECT_MATH);
			else
				ViewManager.instance.openView(ViewManager.VIEW_MATHQUIZ_SETTING_PANEL,false);

			
		}
	}
}